package com.mjw.zstu.controller;

import com.mjw.zstu.entity.ShippingAddress;
import com.mjw.zstu.resultDto.JsonResult;
import com.mjw.zstu.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@CrossOrigin
@RestController
@RequestMapping("address")
public class AddressController {
    @Autowired
    AddressService addressService;

    @RequestMapping("company")
    public JsonResult getcompanylist(int company_id){
       return addressService.Companylist(company_id);
    }
    @RequestMapping("user")
    public JsonResult getuserlist(int user_id){
        return addressService.Userlist(user_id);
    }
    @RequestMapping("add")
    public JsonResult add(@RequestBody ShippingAddress shippingAddress){
        return addressService.add(shippingAddress);
    }
    @RequestMapping("edit")
    public JsonResult edit(@RequestBody ShippingAddress shippingAddress){
        return addressService.edit(shippingAddress);
    }
    @RequestMapping("delete")
    public JsonResult delete(int id){
        return addressService.delete(id);
    }
}
